/****** Object:  StoredProcedure [dbo].[web_renew_groups]    Script Date: 10/19/2013 09:22:25 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'web_renew_groups')
DROP PROCEDURE web_renew_groups
GO

-- =============================================
-- Author:<Author,,Name>
-- Create date: <Create Date,,>
-- Description:<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[web_renew_groups] 
@kodas varchar(100)
AS
BEGIN



SET NOCOUNT ON

BEGIN TRANSACTION
 
delete from n52_sutd_c where N52_c_kodas_kt = @kodas

DECLARE @tmp varchar(100)


DECLARE MY_CURSOR CURSOR 
  LOCAL STATIC READ_ONLY FORWARD_ONLY
FOR 
SELECT kodas
FROM #tt_eilutes

OPEN MY_CURSOR
FETCH NEXT FROM MY_CURSOR INTO @tmp
WHILE @@FETCH_STATUS = 0
BEGIN 

insert into n52_sutd_c (N52_c_kodas_kt,N52_c_kodas_gs ) 
values (@kodas,@tmp)

FETCH NEXT FROM MY_CURSOR INTO @tmp
END
CLOSE MY_CURSOR
DEALLOCATE MY_CURSOR


COMMIT TRANSACTION

END

GO



